// src/utils/validation.js
// Validation utility functions

/**
 * Validate email format
 * @param {string} email - Email to validate
 * @returns {boolean} - True if valid, false otherwise
 */
export const validateEmail = (email) => {
  if (!email) return false;
  
  // Regular expression for email validation
  const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
  return emailRegex.test(email);
};

/**
 * Validate password
 * @param {string} password - Password to validate
 * @returns {boolean} - True if valid, false otherwise
 */
export const validatePassword = (password) => {
  if (!password) return false;
  
  // Minimum password length
  return password.length >= 8;
};

/**
 * Validate username
 * @param {string} username - Username to validate
 * @returns {boolean} - True if valid, false otherwise
 */

export const validateUsername = (username) => {
  if (!username) return false;
  
  // Username can only contain letters (uppercase or lowercase) and must be longer than 3 characters
  const usernameRegex = /^[a-zA-Z]{4,}$/;
  return usernameRegex.test(username);
};
/**
 * Validate city selection
 * @param {string|Array} city - Selected city
 * @returns {boolean} - True if valid, false otherwise
 */
export const validateCity = (city) => {
  if (!city) return false;
  
  // If city is an array (from picker), check if it has items
  if (Array.isArray(city)) {
    return city.length > 0 && !!city[0];
  }
  
  // If city is a string, check if it's not empty
  return !!city;
};

/**
 * Validate avatar upload
 * @param {Array} fileList - Array of uploaded files
 * @returns {boolean} - True if valid, false otherwise
 */
export const validateAvatar = (fileList) => {
  return Array.isArray(fileList) && fileList.length > 0;
};